//
//  WCTChatroom.m
//  WeChatTool
//
//  Created by TerryChe on 2016/12/5.
//  Copyright © 2016年 TerryChe. All rights reserved.
//

#import "WCTChatroom.h"
#import "WCTConfig.h"

@implementation WCTChatroom

+ (instancetype)WCTChatroomByName:(NSString *)name
                       MemberList:(NSString *)memberList
                      DisplayName:(NSString *)displayName
                  SelfDisplayName:(NSString *)selfDisplayName
                       IsShowname:(NSInteger)isShowname
                            Nober:(NSString *)nober{
    return [[self alloc] initWithName:name
                           MemberList:memberList
                          DisplayName:displayName
                      SelfDisplayName:selfDisplayName
                           IsShowname:isShowname
                                Nober:nober];
}

+ (instancetype)WCTChatroomByDic:(NSDictionary *)dic{
    return [[self alloc] initWithName:dic[str_chatroow_name]
                           MemberList:dic[str_chatroow_memberList]
                          DisplayName:dic[str_chatroow_displayName]
                      SelfDisplayName:dic[str_chatroow_selfDisplayName]
                           IsShowname:[dic[str_chatroow_isShowname] integerValue]
                                Nober:dic[str_chatroow_nober]];
}

- (instancetype)initWithName:(NSString *)name
                  MemberList:(NSString *)memberList
                 DisplayName:(NSString *)displayName
             SelfDisplayName:(NSString *)selfDisplayName
                  IsShowname:(NSInteger)isShowname
                       Nober:(NSString *)nober{
    if (self = [super init]) {
        self.name = formatEmptyString(name);
        self.memberList = formatEmptyString(memberList);
        self.displayName = formatEmptyString(displayName);
        self.selfDisplayName = formatEmptyString(selfDisplayName);
        self.isShowname = isShowname;
        self.nober = formatEmptyString(nober);
    }
    
    return self;
}

- (NSDictionary *)convertToDic{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:[WCTConfig sharedInstance].batchCount];
    
    [dic setObject:formatEmptyString(self.name) forKey:str_chatroow_name];
    [dic setObject:formatEmptyString(self.memberList) forKey:str_chatroow_memberList];
    [dic setObject:formatEmptyString(self.displayName) forKey:str_chatroow_displayName];
    [dic setObject:formatEmptyString(self.selfDisplayName) forKey:str_chatroow_selfDisplayName];
    [dic setObject:@(self.isShowname) forKey:str_chatroow_isShowname];
    [dic setObject:formatEmptyString(self.nober) forKey:str_chatroow_nober];
    
    return dic;
}

@end
